"""
字典类似于Java中的map
    1.键值对的key和value可以是任意类型(key不可以为字典)
    2.字典内的key不允许重复，重复添加等同于覆盖原有数据
    3.字典不可以使用下标索引，而是通过key检索value
"""

# 字典定义
my_dict1 = {1: "a", 2: "b", 3: "c"}

# 空字典
my_dict2 = {}
my_dict3 = dict()

print(f"my_dict1内容为：{my_dict1}, 类型为：{type(my_dict1)}")
print(f"my_dict2内容为：{my_dict2}, 类型为：{type(my_dict2)}")
print(f"my_dict3内容为：{my_dict3}, 类型为：{type(my_dict3)}")

# 定义重复的key 后面的key会将前面的key覆盖
my_dict1 = {1: "a", 2: "b", 1: "c"}
print(f"重复key的字典内容为：{my_dict1}")

# 根据Key获取Value值
my_dict1 = {1: "a", 2: "b", 3: "c"}
v1 = my_dict1[1]
print(f"key1对应的value值为：{v1}")

# 字典的嵌套
stu_score_dict = {
    "曹操": {
        "语文": 77,
        "数学": 66,
        "英语": 33
    },
    "刘备": {
        "语文": 88,
        "数学": 86,
        "英语": 55
    },
    "孙权": {
        "语文": 99,
        "数学": 96,
        "英语": 66
    }
}

# 打印嵌套字典
print(f"学生的考试成绩单为：{stu_score_dict}")

# 从嵌套字典中获取数据
score_chinese = stu_score_dict["曹操"]["语文"]
print(f"曹操的语文成绩为：{score_chinese}")
score_math = stu_score_dict["孙权"]["数学"]
print(f"孙权的数学成绩为：{score_math}")
